Masthead


Creating Predictive Maps for Continuous Variables and Point/CSV Files

We now have the tools we need to create predictive maps. The process below can be used to create maps using a wide variety of modeling approaches including linear models, higher-order polynomial models, tree-based models (CART), Generalized Linear Models (GLMs), and Generalized Additive Models (GAMs.). We'll use this approach in the next three labs to create models with different methods.

  1. Create a CSV file with your sample data. This file should contain your response variables and matching predictor variables. There are a variety of ways to create this file but typically you'll:
    1. Obtain a shapefile of points and measured variables.
    2. Extract the values from your predictors for your points.
    3. Export the files as a CSV (BlueSpray) or save it as a shapefile, open the DBF in Excel, and then save it out as a CSV.
  2. Create your model. Use the methods above to create the model.
  3. Create your predictive data. This is a CSV that represents your entire sample area and contains columns for the x and y coordinate values and your predictor variable values for those points.
    1. Start with one of your predictor layers and convert it to a point layer ("To Points" in BlueSpray)
    2. In BlueSpray:
      1. Right-click on the point layer and select the attribute table
      2. Right-click on a column heading in the attribute table and select "Insert Column on Right"
      3. Give the new attribute a good name and the type of "Double". Click "OK"
      4. Right click on the attribute heading and select "Extract"
      5. Select the second predictor layer and select OK. This will add the values from the predictor that contain the specified pixel.
      6. Repeat steps 2 through 5 for each predictor layer
      7. Right click on the layer and select "Export to File".
      8. Give the new file a good name and end it with ".csv" to right out a CSV file.
    3. Open the CSV in Excel and change the file's column headers to exactly match the one's you used in R to create the model.
  4. Predict values for the entire sample area. This step adds predictor values to the CSV file you just created.
    1. Use code similar to the code below to create new predictor values in R.
      ThePrediction=predict(TheModel,NewData) # create a vector of predicted values
      
      FinalData=data.frame(NewData,ThePrediction) # combine the new data and the predicted values
      
      write.csv(FinalData, "C:\\Temp\\ModelOutput.csv")  # Save the prediction to a new file
    2. Load the code into a GIS application and then symbolize the points to see the model!
    3. You may need to change the file's column headers for the GIS app to use the headers.
  5. Create a predicted map. The last step is to convert the points into a raster.
    1. In BlueSpray:
      1. Right click on the point layer and select "Transforms -> To Raster"
      2. The only tricky part is picking the correct resolution for the raster to make sure the pixels match the spacing of the points. The resolution should be the same as the original predictor rasters.

Below is a digram that summarizes this process:

© Copyright 2018 HSU - All rights reserved.